/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * unidad.java
 *
 * Created on 03/09/2011, 10:39:55 AM
 */

package proyectocatalina.mantenimiento;
import CapadeDatos.DaoVerUnidades;
import CapadeDatos.daosemestreunidad;
import LogicadeNegocio.combounidad;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import modelo.beanmodulo;
import modelo.beanunidad;
import modelo.beanunidad2;
import proyectocatalina.Principal;
/**
 *
 * @author hans
 */
public class unidad extends javax.swing.JInternalFrame{
beanmodulo[] modulos;
beanunidad[] bnunidad;
combounidad cbounidad;
    /** Creates new form unidad */
    public unidad() throws Exception {
        initComponents();
       LogicadeNegocio.combomodulo modulo = new LogicadeNegocio.combomodulo(jcombo);
modulo.cargarmodulo();
modulos = modulo.semestre();
jcombo.setSelectedIndex(0);
cbounidad  = new LogicadeNegocio.combounidad(jcombo);
cbounidad.cargarunidad();
bnunidad = cbounidad.semestre();
jcombo.setSelectedIndex(0);
this.jcodunidad.setEnabled(false);
this.jnombreunidad.setEnabled(false);
this.jdescripcion.setEnabled(false);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel3 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jnomunidad = new javax.swing.JTextField();
        jButton3 = new javax.swing.JButton();
        jLabel9 = new javax.swing.JLabel();
        jdescripcion = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jcombo = new javax.swing.JComboBox();
        jLabel2 = new javax.swing.JLabel();
        jcodunidad = new javax.swing.JTextField();
        jPanel1 = new javax.swing.JPanel();
        jLabel7 = new javax.swing.JLabel();
        jcombo1 = new javax.swing.JComboBox();
        jPanel = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jButton4 = new javax.swing.JButton();
        jLabel11 = new javax.swing.JLabel();
        jdescripcion1 = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jcodunidad1 = new javax.swing.JTextField();
        jnombreunidad = new javax.swing.JTextField();
        jPanel2 = new javax.swing.JPanel();
        jbtntodauni = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jtxtcoduni = new javax.swing.JTextField();
        jtxtunidad = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        jbtnbuscaruni = new javax.swing.JButton();
        jLabel14 = new javax.swing.JLabel();
        jtxtmodulo = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        jtxtdescmod = new javax.swing.JTextField();
        jtxtdescuni = new javax.swing.JTextField();
        jLabel16 = new javax.swing.JLabel();
        jtxtestado = new javax.swing.JTextField();
        jLabel17 = new javax.swing.JLabel();
        jbtnchangeestadouni = new javax.swing.JButton();

        setClosable(true);
        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setIconifiable(true);
        setMaximizable(true);
        setResizable(true);

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Inaugurar Unidad", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(0, 102, 255))); // NOI18N

        jLabel5.setText("Nombre de la unidad :");

        jnomunidad.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jnomunidadActionPerformed(evt);
            }
        });

        jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/paper&pencil_48.png"))); // NOI18N
        jButton3.setText("Inaugurar");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jLabel9.setText("Descripcion :");

        jdescripcion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jdescripcionActionPerformed(evt);
            }
        });

        jLabel1.setText("Nombre del modulo :");

        jcombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Por defecto" }));
        jcombo.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jcomboItemStateChanged(evt);
            }
        });
        jcombo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcomboActionPerformed(evt);
            }
        });

        jLabel2.setText("Cod unidad: ");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel6)
                            .addComponent(jLabel2))
                        .addGap(82, 82, 82)
                        .addComponent(jcodunidad, javax.swing.GroupLayout.DEFAULT_SIZE, 190, Short.MAX_VALUE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1)
                            .addComponent(jLabel5)
                            .addComponent(jLabel9))
                        .addGap(6, 6, 6)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jnomunidad, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 190, Short.MAX_VALUE)
                            .addComponent(jdescripcion, javax.swing.GroupLayout.DEFAULT_SIZE, 190, Short.MAX_VALUE)
                            .addComponent(jcombo, 0, 190, Short.MAX_VALUE))))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jcodunidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addGap(20, 20, 20)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel6)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jcombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jnomunidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel5))
                        .addGap(10, 10, 10)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jdescripcion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel9))
                        .addGap(18, 18, 18)
                        .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE))))
        );

        jTabbedPane1.addTab("Inaugurar Unidad", jPanel3);

        jLabel7.setText("Nombre de la unidad :");

        jcombo1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "por defecto" }));
        jcombo1.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jcombo1ItemStateChanged(evt);
            }
        });
        jcombo1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcombo1ActionPerformed(evt);
            }
        });

        jPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Modificar Unidad"));
        jPanel.setEnabled(false);

        jLabel8.setText("Nombre de la unidad :");

        jButton4.setText("Modificar");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jLabel11.setText("Descripcion :");

        jdescripcion1.setEnabled(false);
        jdescripcion1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jdescripcion1ActionPerformed(evt);
            }
        });

        jLabel3.setText("Cod unidad: ");

        jcodunidad1.setEnabled(false);
        jcodunidad1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcodunidad1ActionPerformed(evt);
            }
        });

        jnombreunidad.setEnabled(false);
        jnombreunidad.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jnombreunidadActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanelLayout = new javax.swing.GroupLayout(jPanel);
        jPanel.setLayout(jPanelLayout);
        jPanelLayout.setHorizontalGroup(
            jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelLayout.createSequentialGroup()
                .addGroup(jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelLayout.createSequentialGroup()
                        .addGap(134, 134, 134)
                        .addComponent(jButton4))
                    .addGroup(jPanelLayout.createSequentialGroup()
                        .addGroup(jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanelLayout.createSequentialGroup()
                                .addGap(16, 16, 16)
                                .addComponent(jLabel11))
                            .addGroup(jPanelLayout.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(jLabel10))
                            .addGroup(jPanelLayout.createSequentialGroup()
                                .addGap(20, 20, 20)
                                .addComponent(jLabel3))
                            .addGroup(jPanelLayout.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(jLabel8)))
                        .addGap(30, 30, 30)
                        .addGroup(jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jnombreunidad, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 178, Short.MAX_VALUE)
                            .addComponent(jdescripcion1, javax.swing.GroupLayout.DEFAULT_SIZE, 178, Short.MAX_VALUE)
                            .addComponent(jcodunidad1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 178, Short.MAX_VALUE))))
                .addContainerGap())
        );
        jPanelLayout.setVerticalGroup(
            jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel3)
                    .addComponent(jcodunidad1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(20, 20, 20)
                .addGroup(jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel10)
                    .addGroup(jPanelLayout.createSequentialGroup()
                        .addGroup(jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jnombreunidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel8))
                        .addGap(18, 18, 18)
                        .addGroup(jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jdescripcion1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel11))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 18, Short.MAX_VALUE)
                .addComponent(jButton4)
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addGap(43, 43, 43)
                        .addComponent(jcombo1, 0, 178, Short.MAX_VALUE)
                        .addGap(29, 29, 29))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap())))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(jcombo1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(111, 111, 111))
        );

        jTabbedPane1.addTab("Modificar Unidad", jPanel1);

        jbtntodauni.setText("Mostrar lista de Unidades");
        jbtntodauni.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtntodauniActionPerformed(evt);
            }
        });

        jLabel4.setText("Buscar   Unidad:");

        jLabel12.setText("Ingresar cod de unidad :");

        jtxtcoduni.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                jtxtcoduniFocusGained(evt);
            }
        });

        jtxtunidad.setEditable(false);

        jLabel13.setText("Nombre de unidad :");

        jbtnbuscaruni.setText("Buscar unidad");
        jbtnbuscaruni.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnbuscaruniActionPerformed(evt);
            }
        });

        jLabel14.setText("Nombre modulo :");

        jtxtmodulo.setEditable(false);

        jLabel15.setText("Descripcion modulo :");

        jtxtdescmod.setEditable(false);

        jtxtdescuni.setEditable(false);
        jtxtdescuni.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtxtdescuniActionPerformed(evt);
            }
        });

        jLabel16.setText("Descripcion unidad:");

        jtxtestado.setEditable(false);

        jLabel17.setText("Estado :");

        jbtnchangeestadouni.setText("Cambiar Estado");
        jbtnchangeestadouni.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnchangeestadouniActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel4)
                    .addComponent(jLabel12)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jtxtdescuni, javax.swing.GroupLayout.DEFAULT_SIZE, 209, Short.MAX_VALUE)
                            .addComponent(jtxtunidad, javax.swing.GroupLayout.DEFAULT_SIZE, 209, Short.MAX_VALUE)
                            .addComponent(jtxtcoduni, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 209, Short.MAX_VALUE)
                            .addComponent(jLabel13)
                            .addComponent(jLabel16)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jLabel17)
                                .addGap(23, 23, 23)
                                .addComponent(jtxtestado, javax.swing.GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jtxtmodulo)
                            .addComponent(jbtnbuscaruni, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel14)
                            .addComponent(jLabel15)
                            .addComponent(jtxtdescmod, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jbtnchangeestadouni)
                    .addComponent(jbtntodauni, javax.swing.GroupLayout.PREFERRED_SIZE, 345, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbtntodauni)
                .addGap(9, 9, 9)
                .addComponent(jLabel12)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtxtcoduni, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbtnbuscaruni))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13)
                    .addComponent(jLabel14))
                .addGap(1, 1, 1)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtxtunidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jtxtmodulo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel16)
                    .addComponent(jLabel15))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtxtdescuni, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jtxtdescmod, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel17)
                    .addComponent(jtxtestado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jbtnchangeestadouni)
                .addContainerGap(65, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Dar de baja unidad", jPanel2);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 370, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(19, Short.MAX_VALUE))
        );

        jTabbedPane1.getAccessibleContext().setAccessibleName("Inaugurar Unidad");

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jnomunidadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jnomunidadActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_jnomunidadActionPerformed
int codmodulo=0;
    private void jcomboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcomboActionPerformed
       jcombo.getItemAt(jcombo.getSelectedIndex());
      
    }//GEN-LAST:event_jcomboActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
    
      codmodulo=modulos[jcombo.getSelectedIndex()].getCodmodulo();
      
      CapadeDatos.DaoVerUnidades unidad = new CapadeDatos.DaoVerUnidades();
             unidad.insertarunidad(jcodunidad.getText().toUpperCase(),
                codmodulo,
                jnomunidad.getText().toUpperCase(),
                jdescripcion.getText().toUpperCase()
                );
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jdescripcionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jdescripcionActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jdescripcionActionPerformed

    private void jcomboItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jcomboItemStateChanged
//       codmodulo = modulos[jcombo.getSelectedIndex()].getCodmodulo();  // TODO add your handling code here:
    }//GEN-LAST:event_jcomboItemStateChanged

    private void jcombo1ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jcombo1ItemStateChanged
        // TODO add your handling code here:
}//GEN-LAST:event_jcombo1ItemStateChanged

    private void jcombo1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcombo1ActionPerformed
        this.jnombreunidad.setEnabled(true);
        this.jdescripcion.setEnabled(true);
        if (this.jcombo.getSelectedIndex()>0){
            String cod = bnunidad[jcombo.getSelectedIndex()].getCodunidad();
            String nombre = bnunidad[jcombo.getSelectedIndex()].getNombreunidad();
            String descripcion = bnunidad[jcombo.getSelectedIndex()].getDescunidad();
            jcodunidad.setText(cod);
            jnombreunidad.setText(nombre);
            jdescripcion.setText(descripcion);
        }
}//GEN-LAST:event_jcombo1ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        String codunidad = jcodunidad.getText() ;
        String nombreunidad = jnombreunidad.getText();
        String descripcion = jdescripcion.getText();

        CapadeDatos.DaoVerUnidades actualizar = new DaoVerUnidades();
        actualizar.actualizarunidad(codunidad, nombreunidad, descripcion);
}//GEN-LAST:event_jButton4ActionPerformed

    private void jdescripcion1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jdescripcion1ActionPerformed

}//GEN-LAST:event_jdescripcion1ActionPerformed

    private void jcodunidad1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcodunidad1ActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_jcodunidad1ActionPerformed

    private void jnombreunidadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jnombreunidadActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_jnombreunidadActionPerformed

private void jbtntodauniActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtntodauniActionPerformed
           try {
            proyectocatalina.mantenimiento.listadeunidades ingresar = new   proyectocatalina.mantenimiento.listadeunidades();
            int x = this.getSize().width - ingresar.getSize().width;
            int y = Principal.panel.getSize().height - ingresar.getSize().height;
            ingresar.setLocation(x/2,y/2);
            Principal.panel.add(ingresar);
            ingresar.show();
        } catch (Exception ex) {
            Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
        }
      
}//GEN-LAST:event_jbtntodauniActionPerformed

private void jtxtcoduniFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jtxtcoduniFocusGained





     jbtnchangeestadouni.setEnabled(false);
        // TODO add your handling code here:
}//GEN-LAST:event_jtxtcoduniFocusGained

private void jbtnbuscaruniActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnbuscaruniActionPerformed


               beanunidad2 unidad=new beanunidad2();
     String x="x";

       String cod_uni=jtxtcoduni.getText();
if(cod_uni.length()!=0)
{

 unidad=daosemestreunidad.unidad(cod_uni);

      int k=0;
if (unidad.getCod_unidad().equals(x) ){
JOptionPane.showMessageDialog(null,"Codigo Incorrecto");

}
else{

          jtxtunidad.setText(unidad.getUnidad());
           jtxtmodulo.setText(unidad.getModulo());
 jtxtdescuni.setText(unidad.getUnidaddescripcion());
 jtxtdescmod.setText(unidad.getModulodescripcion());
 jtxtestado.setText(unidad.getEstado());


     }
       }else
        JOptionPane.showMessageDialog(null," DEBE INGRESAR UN CODIGO PARA BUSCAR");




     jbtnchangeestadouni.setEnabled(true);
        // TODO add your handling code here:
}//GEN-LAST:event_jbtnbuscaruniActionPerformed

private void jtxtdescuniActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtxtdescuniActionPerformed

  
        
        // TODO add your handling code here:
}//GEN-LAST:event_jtxtdescuniActionPerformed

private void jbtnchangeestadouniActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnchangeestadouniActionPerformed

        beanunidad2 unidad;
        String cod_uni;
        String estado;
        cod_uni=jtxtcoduni.getText();
        estado=jtxtestado.getText();
        CapadeDatos.daosemestreunidad k =new daosemestreunidad ();
        k.cambiarestadounidad(cod_uni,estado);
        unidad= (beanunidad2)daosemestreunidad.unidad(cod_uni);//recoger datos de alum
        jtxtestado.setText(unidad.getEstado());

        // TODO add your handling code here:
}//GEN-LAST:event_jbtnchangeestadouniActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    new unidad().setVisible(true);
                } catch (Exception ex) {
                    Logger.getLogger(unidad.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JButton jbtnbuscaruni;
    private javax.swing.JButton jbtnchangeestadouni;
    private javax.swing.JButton jbtntodauni;
    private javax.swing.JTextField jcodunidad;
    private javax.swing.JTextField jcodunidad1;
    private javax.swing.JComboBox jcombo;
    private javax.swing.JComboBox jcombo1;
    private javax.swing.JTextField jdescripcion;
    private javax.swing.JTextField jdescripcion1;
    private javax.swing.JTextField jnombreunidad;
    private javax.swing.JTextField jnomunidad;
    private javax.swing.JTextField jtxtcoduni;
    private javax.swing.JTextField jtxtdescmod;
    private javax.swing.JTextField jtxtdescuni;
    private javax.swing.JTextField jtxtestado;
    private javax.swing.JTextField jtxtmodulo;
    private javax.swing.JTextField jtxtunidad;
    // End of variables declaration//GEN-END:variables

}
